import java.awt.event.*;
import javax.swing.*;

public class Example23 extends JFrame{
    private JPopupMenu popuMenu;
    public Example23(){
       
       popuMenu = new JPopupMenu();

       JMenuItem refreshItem = new JMenuItem("refresh");
       JMenuItem createItem = new JMenuItem("create");
       JMenuItem exitItem = new JMenuItem("exit");
    
       exitItem.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){
            System.exit(0);
        }
       });

       popuMenu.add(refreshItem);
       popuMenu.add(createItem);
       popuMenu.add(exitItem);
       popuMenu.addSeparator();
            
       this.addMouseListener(new MouseAdapter(){
           public void mouseClicked(MouseEvent e){
               if(e.getButton()==e.BUTTON3){
                   popuMenu.show(e.getComponent(),e.getX(),e.getY());
               }
           }
       });
        
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setSize(300,300);
        this.setVisible(true);
    }
    public static void main(String[] args){
        new Example23();
    }
}